#include "dialog_password.h"
#include "ui_dialog_password.h"

Dialog_password::Dialog_password(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog_password)
{
    ui->setupUi(this);
    ui->lineEdit_name_2->setEnabled(false);                     //设定不可编辑
    ui->lineEdit_password->setEnabled(false);                   //设定不可编辑
    ui->lineEdit_passwordr->setEnabled(false);                  //设定不可编辑
    ui->pushButton_2->setEnabled(false);

}

Dialog_password::~Dialog_password()
{
    delete ui;
}
/*
 * 设置用户名
 */
void Dialog_password::set_user_name(QString username)
{
    ui->lineEdit_name->setText(username);
    ui->lineEdit_name->setEnabled(false);
}

void Dialog_password::message_1()
{
    QMessageBox::warning(this,"警告","邮箱验证失败",QMessageBox::Yes);
}

void Dialog_password::message_2()
{
    QMessageBox::warning(this,"警告","电话验证失败",QMessageBox::Yes);
}

void Dialog_password::message_3()
{
    QMessageBox::warning(this,"警告","qq验证失败",QMessageBox::Yes);
}

void Dialog_password::message_4()
{
    if(QMessageBox::warning(this,"警告","密码修改成功",QMessageBox::Yes)==QMessageBox::Yes)
    {
        this->close();
    }
}

void Dialog_password::message_5()
{
    if(QMessageBox::warning(this,"警告","密码修改失败",QMessageBox::Yes)==QMessageBox::Yes)
    {
        ui->lineEdit_password->clear();
        ui->lineEdit_passwordr->clear();
        ui->lineEdit_password->setFocus();
    }
}

void Dialog_password::next_do()
{
    ui->lineEdit_name_2->setEnabled(true);                      //设定可编辑
    ui->lineEdit_password->setEnabled(true);                    //设定可编辑
    ui->lineEdit_passwordr->setEnabled(true);                   //设定可编辑
    ui->lineEdit_name->setEnabled(true);                        //设置可编辑
    ui->lineEdit_name_2->setText(ui->lineEdit_name->text());    //为用户名赋值
    ui->lineEdit_name_2->setEnabled(false);             //设置可编辑
    ui->pushButton_2->setEnabled(true);             //激活按钮
}
/*
 * 点击信息有效性验证槽函数
 */
void Dialog_password::on_pushButton_clicked()
{
    //验证信息结构体赋值
    information.succeed_Flag =0;
    information.user_Name=ui->lineEdit_name->text();                   //字符拷贝
    information.user_Phone=ui->lineEdit_phone->text();         //字符拷贝
    information.user_Email=ui->lineEdit_email->text();     //字符拷贝
    information.user_QQ=ui->lineEdit_qq->text();           //字符拷贝
    emit signal_send_psssinformation();             //触发发送信号
}
/*
 * 修改密码槽函数
 */
void Dialog_password::on_pushButton_2_clicked()
{
    if(ui->lineEdit_password->text() != ui->lineEdit_passwordr->text())                 //判断两次密码输入是否相同
    {
        if(QMessageBox::warning(this,"警告","两次密码输入不匹配\n请重新输入",QMessageBox::Yes)==QMessageBox::Yes)               //如果两次输入不同，则弹出信息
        {
            ui->lineEdit_passwordr->setFocus();             //设置焦点
        }
    }
    user_password.succeed_Flag =0;          //设置成功标志
    user_password.user_Name=ui->lineEdit_name->text();                 //字符拷贝
    user_password.user_Password=ui->lineEdit_password->text();         //字符拷贝

    emit signal_send_password();                //触发发送信号


}

